home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 4219 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.2 KB

  1. Path: ix.netcom.com!netnews
  2. From: miker3@ix.netcom.com (Mike Rubenstein)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: What is wrong with this code? (BC45)
  5. Date: Sun, 28 Jan 1996 23:10:50 GMT
  6. Organization: Netcom
  7. Message-ID: <310c01e6.172032896@nntp.ix.netcom.com>
  8. References: <yMOCxg2yqvDD083yn@iaccess.za> <4efqt4$4dd@soap.news.pipex.net>
  9. NNTP-Posting-Host: ix-dc16-21.ix.netcom.com
  10. X-NETCOM-Date: Sun Jan 28  3:10:27 PM PST 1996
  11. X-Newsreader: Forte Agent .99c/16.141
  12.  
  13. Russell Stather <hj11@dial.pipex.com> wrote:
  14.  
  15. > You will get this error if Fred and Mark are global variables as the value 
  16. > of Fred is not known at compile time. If Fred and Mark are local variables 
  17. > to a function then this will be ok.
  18. > If you do want them to be global then you can get this to work by defining 
  19. > them as const.
  20.  
  21. This is true in C, but not in C++.  In C++ initializers of globals may
  22. be arbitrary expressions.
  23.  
  24. Note: since Russell's post did not include the original by Vince Risi,
  25. I reproduce it below:
  26.  
  27. > Why would I get an illegal initialization from this code?
  28.  
  29. > typedef char * pchar;
  30. > pchar Fred = "This is a default value";
  31. > pchar Mark = Fred;    // <------ ????
  32.  
  33. > Is this a BC45 bug?
  34.  
  35.  
  36. Michael M Rubenstein
  37.